package com.aat.dxfy.redis.queue;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class TaskShedulerSystem {

	public static void main(String[] args) throws Exception {
		// 池基本配置
		JedisPoolConfig config = new JedisPoolConfig();
		config.setMaxIdle(5);
		config.setMaxWaitMillis(100L);
		config.setTestOnBorrow(false);
		
		JedisPool jedisPool = new JedisPool(config, "127.0.0.1", 6379, 1000, "redis");
		
		Jedis redisP = jedisPool.getResource();
		Jedis redisC = jedisPool.getResource();

		// 启动一个生产者线程，模拟任务的产生
		new Thread(new TaskProducer(redisP)).start();

		Thread.sleep(15000);

		// 启动一个线程者线程，模拟任务的处理
		new Thread(new TaskConsumer(redisC)).start();

		// 主线程休眠
		Thread.sleep(Long.MAX_VALUE);
	}
}